package https.itmanager.com.springboot.extsample;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor;
import org.springframework.stereotype.Component;

import java.lang.reflect.Constructor;

@Component
public class MySmartInstantiationAwareBeanPostProcessor implements SmartInstantiationAwareBeanPostProcessor {

    @Override
    public Class<?> predictBeanType(Class<?> beanClass,String beanName)throws BeansException {

        return beanClass;
    }



    @Override

    public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, String beanName)throws BeansException{
        System.out.println("MySmartInstantiationAwareBeanPostProcessor determineCandidateConstructors 决定实用bean的哪个构造函数 "+ beanName);
        return null;

    }



    @Override
    public Object getEarlyBeanReference(Object bean,String beanName)throws BeansException{
        System.out.println("MySmartInstantiationAwareBeanPostProcessor getEarlyBeanReference 提前暴露bean 的早期引用 "+ beanName);
        return bean;
    }
}
